import request from './index'

// 商品相关接口
export const productApi = {
    // 获取商品列表
    getList: (params) => {
        return request({
            url: '/product/list',
            method: 'get',
            params
        })
    },
    // 获取商品详情
    getDetail: (id) => {
        return request({
            url: `/product/${id}`,
            method: 'get'
        })
    },
    // 获取推荐商品
    getRecommend: (params) => {
        return request({
            url: '/product/recommend',
            method: 'get',
            params
        })
    },
    // 获取热门商品
    getHot: (params) => {
        return request({
            url: '/product/hot',
            method: 'get',
            params
        })
    },
    // 获取新品
    getNew: (params) => {
        return request({
            url: '/product/new',
            method: 'get',
            params
        })
    },
    // 搜索商品
    search: (params) => {
        return request({
            url: '/product/search',
            method: 'get',
            params
        })
    },
    // 获取商品评价
    getReviews: (productId, params) => {
        return request({
            url: `/product/${productId}/reviews`,
            method: 'get',
            params
        })
    },
    // 提交商品评价
    submitReview: (productId, data) => {
        return request({
            url: `/product/${productId}/reviews`,
            method: 'post',
            data
        })
    }
} 